package com.spring.boot.domain.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.spring.boot.domain.User;

public interface UserRepository extends JpaRepository<User, Long>{
	@Query(value=" FROM User u WHERE u.name LIKE %"+":name"+"% ")
	List<Object> queryName(@Param("name") String name);
	
	@Query(value="SELECT u.* FROM user u WHERE u.name = :name ",nativeQuery=true)
	List<User> queryNameList(@Param("name") String name);
	
	@Modifying
	@Query(value="INSERT INTO USER (NAME,age,phone,email,create_time) " +
			"VALUES ('dsp','5','1234567890','1231231@qq.com',SYSDATE())",nativeQuery=true)
	void insertUser();
	
	@Modifying
	@Query(value="DELETE FROM USER WHERE id IN (?1)",nativeQuery=true)
	Integer deleteUser(Long[] ids);
}
